home *** CD-ROM | disk | FTP | other *** search
Text File | 1996-09-17 | 1.2 KB | 43 lines | [TEXT/MPS ] |
- //========================================================================================
- //
- // File: FWThrdUt.cpp
- // Release Version: $ ODF 2 $
- //
- // Copyright: (c) 1993 - 1996 by Apple Computer, Inc., all rights reserved.
- //
- //========================================================================================
-
- #include "FWOS.hpp"
- #include "FWThrdUt.h"
-
- //-----------------------------------------------------------------------------
- // FW_CThreadCriticalState
- // Enters a critical state and makes sure we exit it if an exception is thrown.
- //-----------------------------------------------------------------------------
-
- FW_DEFINE_AUTO (FW_CPrivThreadCriticalState)
-
- FW_CPrivThreadCriticalState::FW_CPrivThreadCriticalState ()
- {
- OSErr result = ::ThreadBeginCritical();
- FW_FailOnError (result);
- fIsCritical = true;
- }
-
- FW_CPrivThreadCriticalState::~FW_CPrivThreadCriticalState ()
- {
- if (fIsCritical) {
- OSErr result = ::ThreadEndCritical();
- FW_FailOnError (result);
- }
- }
-
- void
- FW_CPrivThreadCriticalState::SetThreadStateEndCritical (ThreadID theThread, ThreadState newState, ThreadID suggestedThread)
- {
- OSErr result = ::SetThreadStateEndCritical (theThread, newState, suggestedThread);
- FW_FailOnError (result);
- fIsCritical = false;
- }
-
-